package com.yyfax.ph.common.utils;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.GlideModule;
import com.yyfax.ph.common.imageselector.utils.FileUtils;

/**
 * Created by laixj on 2017/5/10.
 * Copyright ©2017 www.yylending.com. All Rights Reserved.
 */

public class GlideCache implements GlideModule {

	@Override
	public void applyOptions(Context context, GlideBuilder builder) {
		//设置图片的显示格式ARGB_8888(指图片大小为32bit)
		builder.setDecodeFormat(DecodeFormat.PREFER_ARGB_8888);
		//设置磁盘缓存目录（和创建的缓存目录相同）
		String downloadDirectoryPath = FileUtils.DEFAULT_GLIDE_CACHE;//storageDirectory + "/GlideCache";
		//设置缓存的大小为100M
		int cacheSize = 100 * 1000 * 1000;
		builder.setDiskCache(new DiskLruCacheFactory(downloadDirectoryPath, cacheSize));
	}

	@Override
	public void registerComponents(Context context, Glide glide) {
	}
}
